<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<title>Hammer Time Auctions</title>
</head>
<script language="javascript" type="text/javascript">
	function registerClicked() {
		javascript: register.submit();
	}
</script>
<body>
	<div id="content">
		<%@include file="header.jsp"%>
		<%
			// Check what type of user form this is.
			String form_type = request.getParameter("form_type");
			if (session.getAttribute("form_type") == null) {
				session.setAttribute("form_type", form_type);
			} else if (form_type == null) {
				form_type = (String) session.getAttribute("form_type");
			}
		%>
		<h1>
			Add A New
			<%=form_type%>
		</h1>
		<hr></hr>
		<div class="sidebar right margin-5px padding-5px">
			<%
				// Display the list of registration errors if there are any.
				if (session.getAttribute("register_errors") != null) {
					out.println("<br /><br /><div class=\"section padding-5px error-text\">");
					out.println(session.getAttribute("register_errors"));
					out.println("</div>");
				}
				// Check if there were previously entered values for the form. If there aren't then use an
				// empty string.
				if (session.getAttribute("username") == null) {
					session.setAttribute("username", "");
				}
				if (session.getAttribute("email") == null) {
					session.setAttribute("email", "");
				}
				if (session.getAttribute("first_name") == null) {
					session.setAttribute("first_name", "");
				}
				if (session.getAttribute("last_name") == null) {
					session.setAttribute("last_name", "");
				}
				if (session.getAttribute("address") == null) {
					session.setAttribute("address", "");
				}
				if (session.getAttribute("city") == null) {
					session.setAttribute("city", "");
				}
				if (session.getAttribute("state") == null) {
					session.setAttribute("state", "");
				}
				if (session.getAttribute("zip_code") == null) {
					session.setAttribute("zip_code", "");
				}
				if (session.getAttribute("telephone") == null) {
					session.setAttribute("telephone", "");
				}
				if (form_type.equalsIgnoreCase("customer")) {
					if (session.getAttribute("credit_card_number") == null) {
						session.setAttribute("credit_card_number", "");
					}
					if (session.getAttribute("rating") == null) {
						session.setAttribute("rating", "");
					}
				} else if (form_type.equalsIgnoreCase("employee")) {
					if (session.getAttribute("start_date") == null) {
						session.setAttribute("start_date", "");
					}
					if (session.getAttribute("hourly_wage") == null) {
						session.setAttribute("hourly_wage", "");
					}
					if (session.getAttribute("level") == null) {
						session.setAttribute("level", "");
					}
					if (session.getAttribute("ssn") == null) {
						session.setAttribute("ssn", "");
					}
				}
			%>
		</div>
		<%
			// Create a back button.
			out.println("<a href=\"manage_employees.jsp\" class=\"margin-5px button\">Back</a>");
		%>
		<div class="center" id="register-box">
			<form name="register" action="add_new_user_validate.jsp" method="post">
				<table>
					<tr>
						<td><label class="form-label" for="username">Username:</label></td>
						<td><input name="username" type="text"
							value="<%=session.getAttribute("username")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="password">Password:</label></td>
						<td><input name="password" type="password" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="retype_password">Retype
								Password:</label></td>
						<td><input name="retype_password" type="password" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="email">Email:</label></td>
						<td><input name="email" type="text"
							value="<%=session.getAttribute("email")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="first_name">First Name:</label></td>
						<td><input name="first_name" type="text"
							value="<%=session.getAttribute("first_name")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="last_name">Last Name:</label></td>
						<td><input name="last_name" type="text"
							value="<%=session.getAttribute("last_name")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="address">Address:</label></td>
						<td><input name="address" type="text"
							value="<%=session.getAttribute("address")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="city">City:</label></td>
						<td><input name="city" type="text"
							value="<%=session.getAttribute("city")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="state">State:</label></td>
						<td><input name="state" type="text"
							value="<%=session.getAttribute("state")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="zip_code">ZIP Code:</label></td>
						<td><input name="zip_code" type="text"
							value="<%=session.getAttribute("zip_code")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="telephone">Telephone:</label></td>
						<td><input name="telephone" type="text"
							value="<%=session.getAttribute("telephone")%>" /></td>
					</tr>
					<%
						if (form_type.equalsIgnoreCase("customer")) {
					%>
					<tr>
						<td><label class="form-label" for="credit_card_number">Credit
								Card Number:</label></td>
						<td><input name="credit_card_number" type="text"
							value="<%=session.getAttribute("credit_card_number")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="rating">Rating:</label></td>
						<td><input name="rating" type="text"
							value="<%=session.getAttribute("rating")%>" /></td>
					</tr>
					<%
						} else if (form_type.equalsIgnoreCase("employee")) {
					%>
					<tr>
						<td><label class="form-label" for="start_date">Start Date:</label></td>
						<td><input name="start_date" type="text"
							value="<%=session.getAttribute("start_date")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="start_date">Hourly Wage:</label></td>
						<td><input name="hourly_wage" type="text"
							value="<%=session.getAttribute("hourly_wage")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="level">Level:</label></td>
						<td><input name="level" type="text"
							value="<%=session.getAttribute("level")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" >Social Security:</label></td>
						<td><input name="ssn" type="text"
							value="<%=session.getAttribute("ssn")%>" /></td>
					</tr>
					<%
						}
					%>
					<tr>
						<td></td>
						<td><a href="#" class="right button" type="submit"
							onclick="return registerClicked()">Add New User</a></td>
					</tr>
				</table>
				<input type="submit" class="hidden" />
			</form>
		</div>
	</div>
	<%
		// Clear all the attributes after they have been read.
		session.setAttribute("register_errors", null);
		session.setAttribute("username", null);
		session.setAttribute("email", null);
		session.setAttribute("first_name", null);
		session.setAttribute("last_name", null);
		session.setAttribute("address", null);
		session.setAttribute("city", null);
		session.setAttribute("state", null);
		session.setAttribute("zip_code", null);
		session.setAttribute("telephone", null);
		session.setAttribute("credit_card_number", null);
		session.setAttribute("rating", null);
		session.setAttribute("start_date", null);
		session.setAttribute("hourly_wage", null);
		session.setAttribute("level", null);
	%>
	<hr></hr>
	<%@include file="footer.jsp"%>
</body>
</html>